package com.example.jiaju.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;

import com.example.jiaju.R;
import com.example.jiaju.databinding.BuildTeaseItemBinding;
import com.example.jiaju.databinding.FurnitureInspirationItemBinding;
import com.example.jiaju.entity.BBS;

import java.util.ArrayList;
import java.util.List;

public class BBSAdapter extends RecyclerView.Adapter<BBSAdapter.MyViewHolder> {

    private List<BBS.PageDTO> bbsList = new ArrayList<>();

    public BBSAdapter(List<BBS.PageDTO> bbsList) {
        this.bbsList = bbsList;
    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        BuildTeaseItemBinding binding;
//        switch (select){
////            case 2:  装修暂时先砍掉
//            case 3:{
//                binding= DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()),
//                        R.layout.furniture_inspiration_item,parent,false);
//            }break;
//            default:{
//
//            }break;
//        }

        binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()),
                R.layout.build_tease_item, parent, false);
        MyViewHolder myViewHolder = new MyViewHolder(binding.getRoot());
        myViewHolder.binding1 = binding;
        return myViewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        //填充数据
        holder.binding1.setItem(bbsList.get(position));
    }
    @Override
    public int getItemCount() {
        return bbsList.size();
    }

    static class MyViewHolder extends RecyclerView.ViewHolder{
        BuildTeaseItemBinding binding1;
        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
        }
    }

}
